/* hashTableLib.h - hash table library header file*/


/* Copyright 2003-2005 Neotune Information Technology Co., Ltd. */


#ifndef __INChashTableLibh
#define __INChashTableLibh

#ifdef __cplusplus
extern "C" {
#endif

#include "neos_vx_win.h"


/* status codes */
#define S_hashTableLib_INVALID_ID             (M_hashTableLib | 1)
#define S_hashTableLib_INVALID_NBUCKETS     (M_hashTableLib | 2)
#define S_hashTableLib_INVALID_NELEMENTS    (M_hashTableLib | 3)
#define S_hashTableLib_INVALID_ELEMSIZE     (M_hashTableLib | 4)
#define S_hashTableLib_ALLOC_ERROR             (M_hashTableLib | 5)
#define S_hashTableLib_INVALID_COMPAREFN     (M_hashTableLib | 6)
#define S_hashTableLib_INVALID_HASHFN         (M_hashTableLib | 7)
#define S_hashTableLib_INVALID_ENTRY         (M_hashTableLib | 8)
#define S_hashTableLib_BAD_HASHVALUE         (M_hashTableLib | 9)
#define S_hashTableLib_INVALID_MATCHDATA    (M_hashTableLib | 10)
#define S_hashTableLib_INVALID_PARAM        (M_hashTableLib | 11)
#define S_hashTableLib_INTERNAL_ERROR         (M_hashTableLib | 12)

/* type definitions */

typedef ulong_t HASH_TABLE_ID;

/*
* Hashing function type.  Element is at address <addr>, <nBuckets>
* contains the number of buckets in the table, and <seed> is a user-
* supplied value.  Returns an unsigned integer between 0 and (nBuckets-1).
*/
typedef ulong_t (*HASHFUNCPTR)    ( const void *addr, ulong_t nBuckets, ulong_t seed );

IMPORT HASH_TABLE_ID    hashTableCreate
    ( 
    void *address,
    ulong_t nBuckets,
    ulong_t nElements,
    ulong_t elemSize,
    BUFCFUNCPTR createFn,
    BUFCFUNCPTR destroyFn,
    CMPFUNCPTR compareFn,
    HASHFUNCPTR hashFn,
    ulong_t createArg,
    ulong_t compareArg,
    ulong_t seed
    );
IMPORT HASH_TABLE_ID    hashTableSimpleCreate
    ( 
    ulong_t nBuckets,
    ulong_t nElements,
    ulong_t elemSize,
    CMPFUNCPTR compareFn,
    HASHFUNCPTR hashFn
    );
IMPORT STATUS hashTableDestroy( HASH_TABLE_ID table );
IMPORT void *hashTableAllocEntry( HASH_TABLE_ID table );
IMPORT STATUS hashTableFreeEntry( HASH_TABLE_ID table, void *entry );
IMPORT STATUS hashTableDeleteEntry( HASH_TABLE_ID table, void *entry );
IMPORT void *hashTableAddEntry( HASH_TABLE_ID table, void *entry );
IMPORT void *hashTableSearchForEntry
    ( 
    HASH_TABLE_ID table,
    const void *matchData
    );
IMPORT int hashTableNumEntries( HASH_TABLE_ID table );
IMPORT int hashTableNumCollisions( HASH_TABLE_ID table );
IMPORT STATUS hashTableGetStatistics( 
    HASH_TABLE_ID table,
    ulong_t *avgCollisions,
    ulong_t *maxCollisions
    );
IMPORT STATUS hashTableResetStatistics( HASH_TABLE_ID table );
IMPORT STATUS hashTableShow( HASH_TABLE_ID table );
IMPORT void *hashTableNextEntryUnsorted( HASH_TABLE_ID table, void *entry );
IMPORT ulong_t hashTableGetMemSize( ulong_t nBuckets, ulong_t nElements, ulong_t elemSize );
#else   /* __STDC__ */
IMPORT HASH_TABLE_ID    hashTableCreate( );
IMPORT HASH_TABLE_ID    hashTableSimpleCreate( );
IMPORT STATUS hashTableDestroy( );
IMPORT void *hashTableAllocEntry( );
IMPORT STATUS hashTableFreeEntry( );
IMPORT STATUS hashTableDeleteEntry( );
IMPORT void *hashTableAddEntry( );
IMPORT void *hashTableSearchForEntry( );
IMPORT int hashTableNumEntries( );
IMPORT int hashTableNumCollisions( );
IMPORT STATUS hashTableGetStatistics( );
IMPORT STATUS hashTableResetStatistics( );
IMPORT STATUS hashTableShow( );
IMPORT ulong_t hashTableGetMemSize( );

IMPORT uchar_t  PerfectHashTable[];

#ifdef __cplusplus
}
#endif

#endif

